/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nominalitzacions.domain;

import java.io.IOException;
import nominalitzacions.persistance.NominalizatorDictionaryPersistanceController;

/**
 *
 * @author marc.mauri
 */
public class DictionaryEditionController {

    private NominalizatorDictionaryPersistanceController DPC;
    private NominalizatorDictionary d;

    public DictionaryEditionController() {
        DPC = new NominalizatorDictionaryPersistanceController();
        d = null;
    }

    public DictionaryEditionController(String languageName, String type) {
        DPC = new NominalizatorDictionaryPersistanceController();
        d = DPC.loadDictionary(languageName, type);
    }

    public void loadDictionary(String languageName, String type) {
        d = DPC.loadDictionary(languageName, type);
    }

    public void storeDictionary() throws IOException {
        DPC.storeDictionary(d);
    }

    public Object[] getDictionary() {
        return d.getAllDiccionary().toArray();
    }

    public boolean newDictionary(String languageName, String type) throws IOException {
        boolean b = DPC.newDictionary(languageName, type);
        d = DPC.loadDictionary(languageName, type);
        return b;
    }

    public void mergeDictionary(String path) {
        NominalizatorDictionary vd = DPC.loadDictionary(path);
        d.mergeDictionary(vd);
    }

    public void insertWord(String word) {
        d.add(word);
    }

    public void deleteWord(String word) {
        d.deleteWord(word);
    }

    public void deleteDictionary(String languageName, String type) throws IOException {
        DPC.deleteDictionary(languageName, type);
    }

}

